package design.pattern.Lu16ObserverPattern;

import lombok.Data;

/**
 * @program JavaBase
 * @description: 观察者模式，违反设计原则，很不友好
 * @author: zhanglu
 * @create: 2020-04-10 09:50:00
 */
public class ObserverPattern02 {

    public static void main(String[] args) {
        IHanFeiZi02 hanFeiZi02 = new HanFeiZi02();
        hanFeiZi02.haveBreakfast();
        hanFeiZi02.haveFun();
    }

}

interface IHanFeiZi02{
    void haveBreakfast();
    void haveFun();
}

interface ILiSi02{
    void update(String str);
}

class HanFeiZi02 implements IHanFeiZi02{

    private ILiSi02 liSi02 = new LiSi02();

    @Override
    public void haveBreakfast() {
        System.out.println("我吃饭了");
        liSi02.update("");
    }

    @Override
    public void haveFun() {
        System.out.println("我娱乐了");
        liSi02.update("");
    }

}

class LiSi02 implements ILiSi02{

    @Override
    public void update(String str) {
        System.out.println("监控到他的动作：" + str);
    }
}